﻿<template>
	<div >
		<el-card shadow="hover" :body-style="{ paddingBottom: '0' }">
					<el-form :model="queryParams" ref="queryForm" :inline="true">
						<el-row :gutter="35">
						
			              <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6" >
			              <el-form-item label="设备编码">
			              <el-input v-model="queryParams.num" clearable placeholder="设备编码"/>
			              </el-form-item>
			              </el-col>
						
                
			          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20 search-actions">
         
			          <div>
			          <el-button icon="ele-Refresh" @click="() => queryParams = {}"> 重置 </el-button>
			          <el-button type="primary" plain icon="ele-Search" @click="handleQuery" v-auth="'unitSc:page'"> 查询 </el-button>
			          </div>
			          </el-col>
			      </el-row>
			      </el-form>
	   </el-card>
		<el-card shadow="hover" style="margin-top: 8px">
			<el-table
				:data="tableData"
				style="width: 100%"
				v-loading="loading"
				tooltip-effect="light"
				row-key="id"
				border="">
				<el-table-column type="index" label="序号" width="55" align="center" fixed="" />
				
				 <el-table-column prop="num" label="设备编码" width="100" show-overflow-tooltip="" />

				 <el-table-column  label="模式" width="80" show-overflow-tooltip="" >
					<template #default="scope">
						<el-tooltip content="0-维修；1-手动；2-单机自动；3-联机自动；4-不明。" placement="top" effect="light">
							<span tooltip="">{{ scope.row.mode }}</span>  
                       </el-tooltip>
					    
			       </template>
				 </el-table-column>

				 <el-table-column  label="前叉货物" width="80" show-overflow-tooltip="" 
					 :filters="[
					 	{ text: '有', value: 1 },
					 	{ text: '无', value: 0 },
					 ]"
	      :filter-method="filterExist"
	      filter-placement="bottom-end">
		  <template #default="scope">
				        <el-tag
				          :type="scope.row.frontCargo == 1 ? 'success' : 'info'"
				          disable-transitions >{{ scope.row.frontCargo == 1 ? '有' : '无' }}
						</el-tag>
				      </template>
		</el-table-column>

		  <el-table-column  label="前叉状态" width="80" show-overflow-tooltip="" >

			<template #default="scope">
				<el-tooltip content="0-待机；1-取货中；2-取货完成；3-放货中；4-请求卸货（申请卸货）；5-放货完成；6-取货准备（回库台位）；7-召回；8-急停；9-不明；10-盘库中；11-盘库完成。" placement="top" effect="light">
							<span tooltip="">{{ scope.row.frontCommand }}</span>  
                       </el-tooltip>
			</template>
		  </el-table-column>

		  <el-table-column prop="frontTask" label="前叉任务" width="80" show-overflow-tooltip="" />
		  
		 
			
		  <el-table-column  label="前叉排列层" width="100" show-overflow-tooltip="" >
			<template #default="scope">
					       {{ scope.row.frontZ }}-{{ scope.row.frontX }}-{{ scope.row.frontY }}
			</template>
		  </el-table-column>


		  <el-table-column  label="后叉货物" width="80" show-overflow-tooltip="" 
					 :filters="[
					 	{ text: '有', value: 1 },
					 	{ text: '无', value: 0 },
					 ]"
	      :filter-method="filterExist"
	      filter-placement="bottom-end">
		  <template #default="scope">
				        <el-tag
				          :type="scope.row.backCargo == 1 ? 'success' : 'info'"
				          disable-transitions >{{ scope.row.backCargo == 1 ? '有' : '无' }}
						</el-tag>
				      </template>
		</el-table-column>

		  <el-table-column  label="后叉状态" width="80" show-overflow-tooltip="" >

			<template #default="scope">
				<el-tooltip content="0-待机；1-取货中；2-取货完成；3-放货中；4-请求卸货（申请卸货）；5-放货完成；6-取货准备（回库台位）；7-召回；8-急停；9-不明；10-盘库中；11-盘库完成。" placement="top" effect="light">
							<span tooltip="">{{ scope.row.backCommand }}</span>  
                       </el-tooltip>
			</template>
		  </el-table-column>

		  <el-table-column prop="backTask" label="后叉任务" width="80" show-overflow-tooltip="" />
		  
		 
			
		  <el-table-column  label="后叉排列层" width="100" show-overflow-tooltip="" >
			<template #default="scope">
					       {{ scope.row.backZ }}-{{ scope.row.backX }}-{{ scope.row.backY }}
			</template>
		  </el-table-column>


		  <el-table-column  label="前叉报警" width="80" show-overflow-tooltip="" >

<template #default="scope">
	<el-tooltip content="货叉报警-载货台报警" placement="top" effect="light">
				<span tooltip="">{{ scope.row.frontZError }}-{{ scope.row.frontYError }}</span>  
		   </el-tooltip>
</template>
</el-table-column>

<el-table-column  label="后叉报警" width="80" show-overflow-tooltip="" >

<template #default="scope">
	<el-tooltip content="货叉报警-载货台报警" placement="top" effect="light">
				<span tooltip="">{{ scope.row.backZError }}-{{ scope.row.backYError }}</span>  
		   </el-tooltip>
</template>
</el-table-column>






		  <!-- <el-table-column prop="take_Station1" label="取货站台" width="100" show-overflow-tooltip="" />	
		
		  <el-table-column prop="set_Station1" label="放货站台" width="100" show-overflow-tooltip="" />
				
		  <el-table-column  label="状态" width="100" show-overflow-tooltip="" >

<template #default="scope">
				<el-tag
				  :type="scope.row.state === 0 ? 'danger' : scope.row.state==2?'success':'info'"
				  disable-transitions >{{ scope.row.state === 2 ? '动作中' : scope.row.state===1?'等待中':'未联机' }}
				</el-tag>

				
</template>
</el-table-column> -->

<el-table-column  label="错误信息" show-overflow-tooltip="" >
	    
			      <template #default="scope" >
			   
					<el-tag v-if="scope.row.message" 
			          :type="scope.row.message =='success'?'success':'danger'"
			          disable-transitions >{{ scope.row.message }}
					</el-tag>
			      </template>
			    </el-table-column>
				
				  
				<el-table-column label="操作" width="140" align="center" fixed="right" show-overflow-tooltip="" >
					<template #default="scope">
					
						<el-button icon="ele-Switch" size="small" text="" type="primary" @click="scControl(scope.row)" v-auth="'unitCv:control'"> 调度 </el-button>
					</template>
				</el-table-column>
			</el-table>
			
			<scControlDialog
			    ref="scControlDialogRef"
			    :title="scControlDialogTitle"
			    @reloadTable="handleQuery"
      />

	  <cvTagDialog :tagtype="'sc'" :tagnumber="tagNumber"
			    ref="cvTagDialogRef"
			    			    
      />
			
		</el-card>
	</div>
</template>

<script lang="ts" setup>
	import { ref } from "vue";
	import { ElMessageBox, ElMessage } from "element-plus";
	import { auth } from '/@/utils/authFunction';
	//import { formatDate } from '/@/utils/formatTime';

	import cvTagDialog from '/@/views/main/grpc/unitCv/component/cvTagDialog.vue'
	import { GetProcessData } from '/@/api/main/grpcServer';

	import scControlDialog from '/@/views/main/grpc/unitSc/component/scControlDialog.vue'

		
		const loading = ref(false);
		const tableData = ref<any>([]);
		const queryParams = ref<any>(
		{	
			
		});
	
	const tableParams = ref({
	page: 1,
	pageSize: 10,
	total: 0,
	});
	const tagNumber = ref(0);
	// cv点位详情弹窗
	const cvTagDialogRef=ref();

	const scControlDialogRef = ref();
	

	const scControlDialogTitle = ref("");

	// 查询操作
	const handleQuery = async () => {
	loading.value = true;
	let para={
		nums:queryParams.value.num,
		providerType:5	
		};

		
	
	
	var res = await GetProcessData(para);
	tableData.value = res.data.result ?? [];
	tableParams.value.total = res.data.result?.length;
	loading.value = false;
};



const filterExist = (value: number, row: any) => {
  return row.isExistTray==value;
}



const scControl=async(row:any)=>{

scControlDialogTitle.value = '堆垛机调度';
let data={
	num:row.num,	
	task:10001,
	fork:1,
	command:1
	
}
scControlDialogRef.value.openDialog(data);
};



handleQuery();
</script>


